package comm.android.sherry.servicetest;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MyService extends Service{

    private DownloadBinder mBinder = new DownloadBinder();
    class DownloadBinder extends Binder {
        //开始下载
        public void startDownload() {
            Log.d("MyService","startDownload executed");
        }
        //查看下载进度
        public int getProgress() {
            Log.d("MyService","getProgress executed");
            return 0;
        }
    }

    public IBinder onBind(Intent intent){
        //Log.e("MyService","MyService.onBind()");
        //makeText(this,"onBind()",Toast.LENGTH_SHORT).show();
        return mBinder;//返回该实例
    }
    public void onCreate(){
        Log.e("MyService","MyService.onCreate()");
        Toast.makeText(this,"onCreate()",Toast.LENGTH_SHORT).show();
        super.onCreate();
    }
    public int onStartCommand(Intent intent, int flags, int startId){
        Log.e("MyService","MyService.onStartCommand()");
        Toast.makeText(this,"onStartCommand()",Toast.LENGTH_SHORT).show();
        return super.onStartCommand(intent, flags, startId);
    }
    public void onDestroy(){
        Log.e("MyService","MyService.onDestroy()");
        Toast.makeText(this,"onDestroy()",Toast.LENGTH_SHORT).show();
        super.onDestroy();
    }
    public boolean onUnbind(Intent intent){
        Log.e("MyService","MyService.onUnbind()");
        Toast.makeText(this,"onUnbind()",Toast.LENGTH_SHORT).show();
        return super.onUnbind(intent);
    }
}
